package datamodel;

import org.jdom.Element;
import org.jdom.Namespace;

/**
 * Created by IntelliJ IDEA.
 * User: Qiang
 * Date: 25.11.2008
 * Time: 10:43:36
 */
public class Author implements IXmlWriteable{
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // contructor methode block
    public Author(){/*default contructor*/}

    public Author(String pfirst, String plast) {
        this.last = plast;
        this.first = pfirst;
    }

    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // property block
    private String last;
    private String first;

    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // Getter and Setter block
    public String getLast() {
        return last;
    }

    public void setLast(String last) {
        this.last = last;
    }

    public String getFirst() {
        return first;
    }

    public void setFirst(String first) {
        this.first = first;
    }

    public Element toXMLElement(Namespace ns){
        Element authorElement = new Element("Person", ns);
        authorElement.addContent(new Element("Last", ns).setText(this.last));
        authorElement.addContent(new Element("First", ns).setText(this.first));
        return authorElement;
    }

    public Element toXMLElement(){
        Element authorElement = new Element("Person");
        authorElement.addContent(new Element("Last").setText(this.last));
        authorElement.addContent(new Element("First").setText(this.first));
        return authorElement;
    }

    public void setFieldData(int i, String value) {
        // sparql order ?First ?Last
        switch (i) {
            case 0: this.first = value;
            case 1: this.last = value;
        }
    }

    public String toString() {
        String result ="[Author@"+ this.first +","+this.last +"]";
        return result;
    }

}